<?php
/*
 * (C) Copyright 2013 Torsten Gorath (http://www.blauesdach.de/).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Contributors:
 *     Torsten Gorath
 */
require_once $basedir."/inc/gruppen.php";
require_once $basedir."/inc/gruppenkinder.php";
$gruppen = Gruppen::getAll();
?>
<table>
    <tr>
        <th colspan='2'>Gruppen aktuelles Kindergartenjahr</th>
    </tr>
<?php
$month = date("m");
$year = date("Y");
foreach($gruppen as $gruppe) {
    $kinderliste = GruppenKinder::getAll(true, $gruppe->getId());
?>
    <tr>
        <th class='left'><? echo $gruppe->getName(); ?></th>
        <td><? echo count($kinderliste)."/".$gruppe->getPlaetze(); ?></td>
    </tr>
<?php
}
?>
    <tr>
        <th colspan='2'>Gruppen n&auml;chstes Kindergartenjahr</th>
    </tr>
<?php
foreach($gruppen as $gruppe) {
    if($month>7) {
        $year += 2;
    } else {
        $year += 1;
    }
    $kinderliste = GruppenKinder::getAll(true, $gruppe->getId(), $year."-08-01");
?>
    <tr>
        <th class='left'><? echo $gruppe->getName(); ?></th>
        <td><? echo count($kinderliste)."/".$gruppe->getPlaetze(); ?></td>
    </tr>
<?php
}
?>
</table>